<template>
  <view>
    <uv-popup ref="coupons-popup" round="20" @change="change">
      <view class="popup-container">
        <view class="popup-header">
          <view class="left"></view>
          <p class="center"></p>
          <view class="right">
            <uv-icon class="right" name="close" @click="popupClose"></uv-icon>
          </view>
        </view>
        <view class="popup-main">
          <view class="icon">
            <image class="coupons-icon" :src="$CDN('/customer/static/images/share/avatar-icon.png')" alt="" />
            <text class="title">预约成功</text>
            <text class="tips">管家将尽快联系您看房</text>
          </view>
          <view class="coupons" v-if="coupons && coupons.length">
            <view class="coupons-title">优惠券</view>
            <view v-for="(item, index) in coupons" :key="index" class="coupons-item">
              <view class="count">
                {{ item.amount }}<span>{{ item.title }}</span>
              </view>
              <!-- <view class="date">有效期：2024.04.01-2024.05.31</view> -->
              <view class="date">有效期：{{ item.valid_start }}-{{ item.valid_end }}</view>
              <view class="line"></view>
              <view class="explain">{{ item.instructions }}</view>
            </view>
          </view>
        </view>
      </view>
    </uv-popup>
  </view>
</template>

<script>
import { mapActions, mapGetters } from 'vuex'

export default {
  name: 'componentName',
  components: {},
  mixins: [],
  props: {},
  data() {
    return {
      coupons: [],
    }
  },
  // 侦听属性
  watch: {},
  // 计算属性
  computed: {
    ...mapGetters([]),
  },
  // 监听页面加载，该钩子被调用时data,computed,function,watch,props,slots已设置完成
  onLoad(options) {},
  // 监听页面显示，页面每次出现在屏幕上都触发
  onShow() {},
  // 监听页面初次渲染完成，此时组件已挂载完成
  onReady() {},
  // 下拉刷新
  onPullDownRefresh() {},
  // 加载更多
  onReachBottom() {},

  created() {},
  mounted() {},
  destroyed() {},
  methods: {
    ...mapActions([]),
    open(coupons, reserve_id) {
      this.coupons = coupons
      this.reserve_id = reserve_id
      this.$refs['coupons-popup'].open('bottom')
    },
    popupClose() {
      this.$refs['coupons-popup'].close()
    },
    change({ show }) {
      if (!show) {
        this.$ROUTE.go('/pages/subpackage/appointment/detail', { id: this.reserve_id })
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.popup-container {
  width: 100%;
  height: 1052rpx;
  box-sizing: border-box;
  padding: 35rpx 32rpx 140rpx;
  .popup-header {
    display: flex;
    justify-content: space-between;
    padding: 20rpx 0 40rpx;
    .left {
      width: 32rpx;
      visibility: hidden;
    }
    .center {
      font-weight: bold;
      font-size: 16px;
      color: #333333;
      line-height: 16px;
    }
    .right {
      image {
        width: 50rpx;
        height: 50rpx;
      }
    }
  }
  .popup-main {
    padding: 20rpx 0;
    .icon {
      margin: 20rpx 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      .coupons-icon {
        width: 176rpx;
        height: 176rpx;
      }
      .title {
        margin: 30rpx;
        font-weight: 600;
        font-size: 20px;
        color: #333333;
      }

      .tips {
        font-weight: 400;
        font-size: 28rpx;
        color: #999999;
      }
    }
    .coupons {
      .coupons-title {
        margin-top: 48rpx;
        font-weight: 600;
        font-size: 32rpx;
        color: #333333;
        line-height: 20px;
      }
      .coupons-item {
        margin-top: 20rpx;
        width: 100%;
        box-sizing: border-box;
        border-radius: 16rpx;
        border: 2rpx solid $uv-primary;
        padding: 32rpx 0 0;
        .count {
          font-weight: 600;
          font-size: 64rpx;
          color: $uv-primary;
          line-height: 60rpx;
          padding: 0 24rpx;
          span {
            margin-left: 16rpx;
            font-weight: 500;
            font-size: 28rpx;
            color: #333333;
            line-height: 28rpx;
          }
        }
        .date {
          padding: 0 24rpx;
          margin-top: 24rpx;
          font-weight: 400;
          font-size: 12px;
          color: #333333;
          line-height: 14px;
          margin-bottom: 26rpx;
        }
        .line {
          background: cdn('/common/static/images/png/blue-line.png');
        }
        .explain {
          background: #ecf5f8;
          border-bottom-left-radius: 16rpx;
          border-bottom-right-radius: 16rpx;
          box-sizing: border-box;
          width: 100%;
          padding: 24rpx;
          font-weight: 400;
          font-size: 10px;
          color: #999999;
        }
      }
    }
  }
}
</style>
